﻿<html>
<head>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
$(document).ready(function(){
var token ='';
  $("#b01").click(function(){
    $.ajax({
      //type: 'post',
      url: 'ApiService.svc/GetToken',
      //contentType: 'application/json;charset=utf-8',
      data: { "userName": "admin", "password": "202CB962AC59075B964B07152D234B70" },
      success: function (data) { //??json??
      var dd = eval("(" + data.Data + ")");
          $("#myDiv").text(dd.User_Name);
          //$.cookie('token', dd.password);
          token = dd.User_Password;
          console.log(token);
      }
    });
    });
    $("#b02").click(function(){
    $.ajax({
      //type: 'post',
      //headers: {'Cookie' : document.cookie },
      url: 'ApiService.svc/GetJson?s=SystemPage_Type&p=@cUserId:ec0cd9f0-30ec-44f2-b857-ea969c30c92b&token=' +token,
      //contentType: 'application/json;charset=utf-8',
      //data: '{"name": "uname", "age": 18}',
            crossDomain: true,
      success: function (data) { //??json??
          $("#myDiv").text(data.Data);
          //$.cookie('token', dd.password);
      }
    });
    //http://192.168.2.200:4824/ApiService.svc/GetJson?s=SystemAppMenu_User&p=@cUserId:ec0cd9f0-30ec-44f2-b857-ea969c30c92b
  });

});
    </script>
</head>
<body>
    <div id="myDiv"><h2>Ajax</h2></div>
    <button id="b01" type="button">登录</button>
    <button id="b02" type="button">读数</button>
</body>
</html>